package org.example.test.eight;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import org.example.test.util.RabbitMQUtils;

/**
 * @Author: 以默
 * @Date: 2024/7/18 17:02
 *
 * 死信队列之生产者
 */
public class Producer {
    public static final String NORMAL_EXCHANGE = "normal_exchange";
    public static final String DEAD_QUEUE = "dead";
    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();
        // 发送死信消息,设置TTL时间
//        AMQP.BasicProperties properties =
//                new AMQP.BasicProperties()
//                        .builder().expiration("10000").build();

        for (int i = 1; i < 11; i++) {
            String message = "info" + i;
            channel.basicPublish(NORMAL_EXCHANGE, "zhangsan", null, message.getBytes());
        }
    }
}
